


#include <iostream>
#include <forward_list>
#include <list>
#include <algorithm>

using namespace std;

#define MAX_RST_LIST_SIZE 50

list<int> rst_list;

bool util_find(int value) {
    auto pos = std::find(rst_list.cbegin(), rst_list.cend(), value);
    return pos != rst_list.cend();
}

void util_remove_last() {
    rst_list.pop_back();
}

void util_insert(int value) {
    if (rst_list.size() < MAX_RST_LIST_SIZE) {
        rst_list.push_front(value);
    } else {
        util_remove_last();
        rst_list.push_front(value);
    }
}

void util_print() {
    for(auto value: rst_list)
        cout << value << endl;
}

int main() {

    bool ret = util_find(100);
    if ( !ret ) {
        cout << "can't find 100" << endl;;
    }    

    for (int i = 0; i < MAX_RST_LIST_SIZE; i++) {
        util_insert(i);
    }
    cout << "print " << endl;
    util_print();

    util_insert(100);
    util_insert(101);

    util_print();

    ret = util_find(100);
    if ( ret ) {
        cout << "find 100" << endl;;
    }    

    ret = util_find(35);
    if ( ret ) {
        cout << "find 35" << endl;;
    }    

    ret = util_find(200);
    if ( !ret ) {
        cout << "can't find 200" << endl;;
    }    
}